package com.ailanyin.soft.utils;

import cn.hutool.core.util.RuntimeUtil;

/**
 * Linux 工具类
 *
 * @author ailanyin
 * @version 1.0
 * @since 2022-1-7 11:12:01
 */
public class LinuxUtil {

    public static void openPort(Integer port) {
        System.out.println("========== 正在开启 " + port + " 防火墙端口 ==========");
        RuntimeUtil.getResult(RuntimeUtil.exec("firewall-cmd --zone=public --add-port=" + port + "/tcp --permanent"));
        RuntimeUtil.getResult(RuntimeUtil.exec("firewall-cmd --reload"));
        System.out.println("========== 开启完成 " + port + " 防火墙端口 ==========");
    }
}
